********************************************************************************
/*

This file provides the Stata code necessary to construct the dataset used in 
Matthew Fuhrmann and James D. Kim, "Socialization, Self-Selection, and 
the Life Experiences of World Leaders: Why Business Experience Influences 
Defense Spending," The Journal of Politics, forthcoming

Date: October 26, 2024

*/
********************************************************************************

********************************************************************************
*Begin by changing the directory 
*Note to users: modify the line of code below so that it matches the relevant location on your computer
********************************************************************************

cd "/Users/jamesdkim/Library/CloudStorage/Dropbox/Experience Mechanisms/JOP data construction"

*Begin with data on post-office business experience
use "Business Coding - Post-Office.dta", clear

*Fix data for Kohl (Germany) -- he is included for ccode 255 and 260 but only coded in the Excel file for 260
drop if leadername=="Kohl" & ccode==255

drop if ccode==.
replace post_business=0 if post_business==.
replace lenient_post_business=0 if lenient_post_business==.
replace post_business_consultant = 0 if post_business_consultant == .

sort leadername
save "Business Coding - merge", replace

*Bring in Fuhrmann (2020) "When do leaders free-ride" dataset
use defense_spending, clear

*Merge post-office business experience
sort  leadername 
merge  leadername using "Business Coding - merge"
drop _merge

*Merge LEAD Dataset
sort  leadername 
merge  leadername using "LEAD-leadername"
drop if _merge==2

*Recode post-office business variables: missing values to 0 
replace post_business=0 if post_business==.
replace lenient_post_business=0 if lenient_post_business==.
replace post_business_consultant = 0 if post_business_consultant == .
*Generate three categories based on pre- and post-office experience: /// 
/*
1. No pre- or post-office business experience ///
2. Pre-office business experience ///
3. Post-office business experience without pre-office experience
*/

g nobiz=0
replace nobiz=1 if business==0 & post_business==0
la var nobiz "No pre- or post-office business experience (Main coding)"

g postbizonly=0
replace postbizonly=1 if post_business==1 & business==0

g nobiz_alt=0
replace nobiz_alt=1 if business==0 & lenient_post_business==0

g postbizonly_alt=0
replace postbizonly_alt=1 if lenient_post_business==1 & business==0
la var nobiz_alt "No pre- or post-office business experience (lenient)"

g nobiz_consultant=0
replace nobiz_consultant=1 if business==0 & post_business_consultant==0

g postbizonly_consultant=0
replace postbizonly_consultant=1 if post_business_consultant==1 & business==0
la var nobiz_consultant "No pre- or post-office business experience (consultants)"

**Dealing with missing 
replace postbizonly = . if business ==. 
replace nobiz = . if business ==. 

*Generate low, non-executive-level experience: /// 
/*
1. No business experience ///
2. low-level business experience ///
3. high-level (executive) experience
*/

g low_business=0
replace low_business=1 if business_LEAD==1 & business==0
la var low_business "Low-level business experience only"


g business_low=business
replace business_low = 1 if business_LEAD==1


g nobiz_low=0
replace nobiz_low=1 if business_low ==0 & post_business==0

g postbizonly_low=0
replace postbizonly_low=1 if post_business==1 & business_low==0


* generate post-cold war dummy
gen post_cw = 0 
replace post_cw = 1 if year >1988


sort ccode year
xtset ccode year

* Generage business variable excluding BoD cases
gen business_nobod = business
replace business_nobod = 0 if leadername == "Elio Di Rupo"
replace business_nobod = 0 if leadername == "Van Rompuy"
replace business_nobod = 0 if leadername == "Biesheuvel" 
replace business_nobod = 0 if leadername == "Lubbers"
replace business_nobod = 0 if leadername == "Turgut Ozal"
replace business_nobod = 0 if leadername == "Cameron"

gen postbiz_nobod = 0
replace postbiz_nobod = 1 if leadername == "van Agt"
replace postbiz_nobod = 1 if leadername == "Spaak"
replace postbiz_nobod = 1 if leadername == "van Houtte"
replace postbiz_nobod = 1 if leadername == "Clark"
replace postbiz_nobod = 1 if leadername == "de Quay"
replace postbiz_nobod = 1 if leadername == "Thorn G."
replace postbiz_nobod = 1 if leadername == "Cals"
replace postbiz_nobod = 1 if leadername == "Eyskens, G."
replace postbiz_nobod = 1 if leadername == "Leterme"
replace postbiz_nobod = 1 if leadername == "Willoch"
replace postbiz_nobod = 1 if leadername == "St. Laurent"
replace postbiz_nobod = 1 if leadername == "Pearson"
replace postbiz_nobod = 1 if leadername == "Dehaene"
replace postbiz_nobod = 1 if leadername == "Eyskens, M."
replace postbiz_nobod = 1 if leadername == "Harper"
replace postbiz_nobod = 1 if leadername == "Fogh Rasmussen"
replace postbiz_nobod = 1 if leadername == "Thorn G."
replace postbiz_nobod = 1 if leadername == "Kok"
replace postbiz_nobod = 1 if leadername == "de Quay"
replace postbiz_nobod = 1 if leadername == "Kwasniewski"
replace postbiz_nobod = 1 if leadername == "Gonzalez Marquez"
replace postbiz_nobod = 1 if leadername == "Blair"

*Generate three categories based on pre- and post-office experience:
gen nobiz_nobod= 0
replace nobiz_nobod=1 if business_nobod==0 & postbiz_nobod==0
la var nobiz_nobod "No pre- or post-office business experience (excluding BoD)"

g postbizonly_nobod=0
replace postbizonly_nobod=1 if postbiz_nobod==1 & business==0
la var postbizonly_nobod "Post-office business experience only (excluding BoD)"

sort ccode year
xtset ccode year

** defense spending trends and business leaders
*Create defense spending trend variable (3 years) 
by ccode: gen dstrend_3 = (defspend_ch[_n-1] + defspend_ch[_n-2] + defspend_ch[_n-3]) / 3

*Create defense spending trend variable (5 years) 
by ccode: gen dstrend_5 = (defspend_ch[_n-1] + defspend_ch[_n-2] + defspend_ch[_n-3] + defspend_ch[_n-4] + defspend_ch[_n-5] ) / 5

* Defense spending trend and "election" of business leaders
gen turnover = . 
replace turnover = 1 if leadername[_n] != leadername[_n-1]

gen new_business = . 
recode new_business .=0 if turnover == 1
recode new_business 0=1 if business == 1


* Merge TNL Dataset
drop _merge
sort ccode year
merge  ccode year using "ted_merge"
sort ccode year

drop if _merge==2
drop _merge

* merge age, gender, outyear variables (updated by the author from the LEAD dataset) 
merge ccode year using "LEAD-updated" 
drop _merge
sort ccode year 

* Drop unneeded variables
drop nothing post_business_2 lenient_post_business_1 Lentz Othersources postofficejob Sources Note Otherjobs source1-source6 treatment

* Update variable labels
la var post_business "leader has post-office business experience"
la var lenient_post_business "post_business with more lenient coding"
la var post_business_consultant "post_business including consultants"

la var mids_per_yr "number of military disputes per year"
la var postbizonly "only post-office business experience"
la var postbizonly_alt "only post-office business experience - more lenient coding"
la var postbizonly_consultant "include consultants as post-office business experience"
la var business_low "low-level business experience from LEAD"
la var nobiz_low "no low-level business experience"
la var postbizonly_low "only low-level post-office business experience"
la var post_cw "post-cold war" 
la var business_nobod "same as business but excluding board of directors service"
la var postbiz_nobod "post-office business experience excluding board of directors service"
la var nobiz_nobod "no business experience with board of directors service excluded"
la var postbizonly_nobod "only post-office business experience with board of directors service excluded"
la var dstrend_3 "three-year defense spending trend"
la var dstrend_5 "five-year defense spending trend"
la var turnover "leadership turnover"
la var new_business "new business leader"

*Order variables
order ccode-finance post_business lenient_post_business post_business_consultant nobiz-new_business

*Save
save BEM-JOP-final, replace
